//解构对象
let obj = {
    name: 'jack',
    age: 20,
    address:'北京顺义'
}

let obj2 = {
    salary: '20k',
    zhuanye:'前端开发'
}

// for (let key in obj2) { 
  
//     obj[key]=obj2[key]
// }
//   console.log('obj:',obj)

let res = { ...obj, ...obj2 }
console.log('res:',res)


// let a = obj.name
// let b = obj.age
// let c1 = obj['address']

let {name:username,age:nianling}=obj
console.log('username:',username)
console.log('nianling:', nianling)

//合并数组  结果：[4, 5, 2, 23, 32,'aa', 'bb', 'cc']
let arr1 = [4, 5, 2, 23, 32]
let arr2 = ['aa', 'bb', 'cc']

let result = [...arr1, ...arr2]
console.log('result:', result)

//rest操作
function sum(title,a,...args) {
    console.log('title:',title)
    console.log('a:',a)
    console.log('args:',args)
   let result = 0;
    for (let i = 0; i < args.length; i++) {
      
        result+=args[i]
    }

    return result;
}

console.log(sum('求和的结果：',1,2,3))

